import Vue from "vue";
import loading from "./index.vue";
const loadingConstructor = Vue.extend(loading);
export default function (durang) {
  loadingConstructor.prototype.close = function () {
    if (this.$el && this.$el.parentNode) {
      this.$el.parentNode.removeChild(this.$el);
    }
    this.$destroy();
  };
  const loadingInstance = new loadingConstructor();
  loadingInstance.$mount();
  document.body.appendChild(loadingInstance.$el);
  if (durang && typeof durang === "number") {
    setTimeout(() => {
      loadingInstance.close();
    }, durang);
  }
  return loadingInstance;
}
